<?php
	require_once("../conexion/conexion.php");
	
	extract($_POST);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />
<link type="text/css" href="../Estilos/autocompletar.css" rel="stylesheet" />
<script src="../include_js/jquery.js" type="text/javascript"></script>
<!--<script type="text/javascript" src="../include_js/jquery-1.6.2.min.js"></script>-->
<script type="text/javascript" src="../include_js/jquery-ui-1.8.15.custom.min.js"></script>
<style>
.texto
{
	font-weight:bold;
	font-size:14px;
	color:#5A79A0;
}
.borde
{
	border:0px solid #6593C0;
}
</style>
<script>
$(document).ready(function()
{ 
	$('#txt_Nombre').autocomplete({
		source:'Autocompletar_RepAcc.php',
		select: function(event,ui){
		
			document.getElementById('txt_Nombre').value = ui.item.value;
			document.getElementById('txt_Marca').value = ui.item.marca;
			document.getElementById('txt_Modelo').value = ui.item.modelo;
			document.getElementById('txt_Amperaje').value = ui.item.amp;
			document.getElementById('txt_Voltaje').value = ui.item.volt;
			document.getElementById('txt_Medida').value = ui.item.medida;
			document.getElementById('txt_Id').value = ui.item.id;
		}
	});
});

function BorraDatos(dato)
{
	var cadena = dato.substring(8,9);
    if(cadena=='1')
	{
		document.form_neumatico.submit();
	}
	else
	{
		document.getElementById('txt_Nombre').value = '';
		document.getElementById('txt_Marca').value = '';
		document.getElementById('txt_Modelo').value = '';
		document.getElementById('txt_Amperaje').value = '';
		document.getElementById('txt_Voltaje').value = '';
		document.getElementById('txt_Medida').value = '';
		document.getElementById('txt_Id').value = '';
		document.getElementById('txt_Nombre').focus();
	}
}
function Foco()
{
	document.getElementById('txt_Nombre').focus();
}

$("#VerDatos").click(function(event) 
{
	//$("#FondoPantalla").css("display", "block");
	//$("#VentanaEmergente").css("display", "block");
	 $.ajax({
            type: 'POST',
            url: 'Tabla_RepAcc.php',
            data: $('#form_neumatico').serialize(),
            success: function(data) {
                $('#tabla').html(data);
				document.getElementById('tabla').style.display='block';
				document.location.href = '#abajo';
            }
        })
});

function Borrar(e,txt) { 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8)
	{ //Tecla de retroceso (para poder borrar) 
	
	//document.getElementById('txt_Nombre').value = '';
	document.getElementById('txt_Marca').value = '';
	document.getElementById('txt_Modelo').value = '';
	document.getElementById('txt_Amperaje').value = '';
	document.getElementById('txt_Voltaje').value = '';
	document.getElementById('txt_Medida').value = '';
	document.getElementById('txt_Id').value = '';
	//return true;
	}
	else
	{
		//alert('paso2');
	document.getElementById('txt_Marca').value = '';
	document.getElementById('txt_Modelo').value = '';
	document.getElementById('txt_Amperaje').value = '';
	document.getElementById('txt_Voltaje').value = '';
	document.getElementById('txt_Medida').value = '';
	document.getElementById('txt_Id').value = '';
	}
} 
</script>
</head>

<body>
<form name="form_neumatico" id="form_neumatico" method="post">
<script>
	Foco();
</script>
<div class="infopop">
<table width="100%" border="0" cellpadding="2" cellspacing="0">
<tr>
  <td width="35%" class="borde" style="text-align:right;">&nbsp;</td>
  <td width="2%" class="borde" style="text-align:right;">&nbsp;</td>
  <td width="63%" class="borde"><input name="txt_Id" id="txt_Id" type="hidden" /></td>
</tr>

<tr>
  <td class="borde" style="text-align:right;"><label class="texto">Nombre:</label></td>
  <td class="borde" style="text-align:right;">&nbsp;</td>
  <td class="borde"><input type="text" name="txt_Nombre" id="txt_Nombre" size="50" onkeypress="return Borrar(event,this)" onfocus="this.select()" /></td>
</tr>
<tr>
  <td class="borde" style="text-align:right;"><label class="texto">Marca:</label></td>
  <td class="borde" style="text-align:right;">&nbsp;</td>
  <td class="borde"><input type="text" name="txt_Marca" id="txt_Marca" size="50" /></td>
</tr>
<tr>
  <td class="borde" style="text-align:right;"><label class="texto">Modelo:</label></td>
  <td class="borde" style="text-align:right;">&nbsp;</td>
  <td class="borde"><input type="text" name="txt_Modelo" id="txt_Modelo" size="50" /></td>
</tr>
<tr>
  <td class="borde" style="text-align:right;"><label class="texto">Amperaje:</label></td>
  <td class="borde" style="text-align:right;">&nbsp;</td>
  <td class="borde"><input type="text" name="txt_Amperaje" id="txt_Amperaje" /></td>
</tr>
<tr>
  <td class="borde" style="text-align:right;"><label class="texto">Voltaje:</label></td>
  <td class="borde" style="text-align:right;">&nbsp;</td>
  <td class="borde"><input type="text" name="txt_Voltaje" id="txt_Voltaje" /></td>
</tr>
<tr>
  <td class="borde" style="text-align:right;"><label class="texto">Medida:</label></td>
  <td class="borde" style="text-align:right;">&nbsp;</td>
  <td class="borde"><input type="text" name="txt_Medida" id="txt_Medida" /></td>
</tr>
<tr>
  <td class="borde" style="text-align:right;">&nbsp;</td>
  <td class="borde" style="text-align:right;">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde" style="vertical-align:bottom;"><div style="border:1px solid #000000; width:125px; padding:5px;" onmouseover="this.style.background='#E1E1E1';" onmouseout="this.style.background=''"><a id="VerDatos" href="#"><label style="color:#CC3300;font-weight:bold; font-size:12px">Ver Datos Ingresados</label></a></div></td>
  <td class="borde" style="text-align:right;">&nbsp;</td>
  <td class="borde"><input name="btn_Guardar" id="btn_Guardar" type="button" value=" " class="guardar" /></td>
</tr>
</table>
</div>
<div id="respuesta"></div>

</form>
</body>
<script>
$('#btn_Guardar').click(function() 
{ 
        $.ajax({
            type: 'POST',
            url: '../IngresaMantenedores/IngresaRepAcc.php',
            data: $('#form_neumatico').serialize(),
            success: function(data) {
                $('#respuesta').html(data);
				BorraDatos(data);
            }
        })
});
</script>
</html>
